package ezXpns.tests;

import static org.junit.Assert.*;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.File;

import org.junit.Test;

import ezXpns.Profile;


//@author A0086934R
public class ProfileTest {

	@Test
	public void testConstructor() {
		Profile p1 = new Profile();
		
		assertNotNull(p1);
	}

	@Test
	public void testChange() {
		Profile p2 = new Profile();
		
		assertTrue(p2.getBudget() == 1000.0f);
		
		p2.setBudget(2000.0f);
		assertTrue(p2.getBudget() == 2000.0f);
		
		try {
			p2.save("temp.txt");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		Profile p3 = new Profile();
		try {
			p3.load("temp.txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		assertTrue(p3.getBudget() == 2000.0f);
		
		File file = new File("temp.txt");
		file.delete();
	}
}
